const Koa = require('koa')
const path = require('path')
const bodyparser = require('koa-bodyparser')
const koaStatic = require('koa-static')
const koaBody = require('koa-body')
const Router = require('koa-router')
const fs = require('fs')
var cors = require('koa-cors');

const port = 3000

const app = new Koa()
app.use(cors());
app.use(koaBody({
  multipart: true,
  formidable: {
      maxFileSize: 200*1024*1024    // 设置上传文件大小最大限制，默认2M
  }
}));

// 静态资源
// app.use(koaStatic(__dirname))
// 请求体解析
// app.use(bodyparser())

// 路由
app.use(require('./routes/user.js').routes())
app.use(require('./routes/upload.js').routes())
app.use(require('./routes/product.js').routes())

app.listen(port, ()=> { console.info(`项目启动成功，端口号为${port}`) })